import pandas as pd

# 1.读取数据
data0 = pd.read_csv("../../resources/p00_data_mining/stock_day.csv", usecols=["high", "low", "open", "close"]).head() # 读哪些列
data = pd.read_csv("../../resources/p00_data_mining/stock_day2.csv", names=["open", "high", "close", "low", "volume", "price_change", "p_change", "ma5", "ma10", "ma20", "v_ma5", "v_ma10", "v_ma20", "turnover"]) # 如果列没有列名，用names传入

# 2.写入数据
data[:10].to_csv("../../resources/p00_data_mining/test1.csv", columns=["open"]) # 保存open列数据前10行
data[:10].to_csv("../../resources/p00_data_mining/test2.csv", columns=["open"], index=False, mode="a", header=False) # 保存opend列数据，index=False不要行索引，mode="a"追加模式|mode="w"重写，header=False不要列索引
